<%@ taglib uri="/tld/extremecomponents" prefix="ec" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

	<script src = "../js/jquery-1.12.1.js" type = "text/javascript"></script>
	<script src = "../js/common.js" type = "text/javascript"></script>
	
	<link href="<%=request.getContextPath() %>/css/extremecomponents.css" rel="stylesheet" type="text/css" />
	<link href="<%=request.getContextPath() %>/css/global.css" rel="stylesheet" type="text/css" />
<title>Insert title here</title>
</head>
<script>
	//状态框回显
	$(function() {
	$("select[name='COURSE_TYPE']").val('<c:out value="${CONDITIONMAP.courseType}" />');
	$
	});
	
    $(function() {
        //查询
        $("#btnsearch").click(
            function() {
                formPost(window.SearchState, '','course?ActionType=course_Manage', this);
            });
        //创建课程
        $("#btnadd").click(
            function() {
            	formPost(window.SearchState, '','course?ActionType=course_Add_Update_Init&FLAG=add', this);
            });
    });
    
  //删除课程
    function deleteCourse(course_id){
    	console.log(course_id);
    		 var msg = "将删除与班级程相关的所有信息,请谨慎操作！"; 
    		 if (confirm(msg)==true){ 
    			 $.ajax({
    		            type : "post",
    		            dataType : "text",
    		            url : "course?ActionType=course_Delete",
    		            data : {"COURSE_ID":course_id},
    		            success : function(massage) {
    		                if (massage == 'success') {
    		                	goTo("course?ActionType=course_Manage");
    		                }else{
    		                	alert("删除班级信息失败！");
    		                }
    		            }
    		        });
    		 }else{ 
    		   return false; 
    		 } 
    }
</script>
<body>
<div id="current">当前位置：基础数据管理 &gt; 课程管理</div>
<form name="SearchState" method="post">
  <table width="100%" border="0" cellpadding="0" cellspacing="0" class="search_table">
    <tr class="search_title_tr">
      <td colspan="4" class="search_title_L"><img src="../images/search_titleleft.jpg" width="84" height="30" align="top" /></td>
      <td width="25%" class="search_title_R"><img src="../images/search-titleright.jpg" width="8" height="30" align="top" /></td>
    </tr>
    <tr>
      <td width="12%" class="search_td1">课程：</td>
      <td width="25%" class="search_td2">
        <input name="COURSE_NAME" type="text" size="16" value="<c:out value='${CONDITIONMAP.courseName}' />" />
      </td>
      <td width="12%" class="search_td1">学分：</td>
      <td colspan="2" class="search_td2">
        <input name="CREDITS" type="text" size="16" value="<c:out value='${CONDITIONMAP.credits}' />" />
      </td>
    </tr>
    <tr>
      <td width="12%" class="search_td1">课时：</td>
      <td width="25%" class="search_td2">
        <input name="COURSE_HOUR" type="text" size="16" value="<c:out value='${CONDITIONMAP.courseHour}' />" />
      </td>
      <td width="12%" class="search_td1">课程性质：</td>
      <td width="26%" class="search_td2">
        <select name = "COURSE_TYPE" id = "COURSE_TYPE">
        	<option value = "1" >重修</option>
        	<option value = "2">必修</option>
        	<option value = "3" >选修</option>
        </select>
      </td>
      <td class="search_td2">
      <input id="btnsearch" name="btnsearch" type="button" class="btn_2" value="查询" />
      <input id="btnadd" name="btnadd" type="button" class="btn_4" value="新建课程" /></td>
    </tr>
  </table>
  </form>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
    <tr>
        <td class="search_shadow"></td>
    </tr>
    <tr>
        <td class="main_blank"></td>
    </tr>
</table>
<!--数据列表-START-->
<ec:table items="COURSEINFO" var="row"
    action="course?ActionType=course_Manage"
    view="html" 
    autoIncludeParameters="false"
     >
    <ec:exportXls fileName="courseList.xls" />
    <ec:row>
        <ec:column style="text-align:center;" width="7%" property="rowcount" cell="rowCount" title="序号" sortable="false"/>
        <ec:column property="course_name" style="text-align:center;" title="课程名称" />
        <ec:column property="course_hour" style="text-align:center;" title="课时" />
        <ec:column property="credits" style="text-align:center;" escapeAutoFormat="true" sortable="false" title="学分" />
         <ec:column property="course_type" style="text-align:center;" title="课程性质">
         <c:choose>
			    <c:when test="${row.course_type == '1'}">重修
			    </c:when>
			    <c:when test="${row.course_type == '2'}">必修
			    </c:when>
			    <c:otherwise>选修
			    </c:otherwise>
		    </c:choose>
		 </ec:column>
        <ec:column property="EDIT" style="text-align:center;" title="操作" viewsDenied="xls">
        	<a href="#" onClick="formPost(window.SearchState,'','course?ActionType=course_Add_Update_Init&FLAG=update&COURSE_ID=<c:out value="${row.course_id}"/>',this);">修改</a> 
		   	|  <a href="#" onClick="deleteCourse('<c:out value="${row.course_id}"/>')">删除</a>
        </ec:column>
    </ec:row>
</ec:table>
</body>
</html>